FROM golang:1.21 as builder
# COPY local code to the container image
WORKDIR /
COPY . .
COPY static .
# Build the command inside the container
RUN CGO_ENABLE=0 GOOS=linux go build -v -o main

# Use a Docker multi-stage build to create a lean production image.
FROM alpine as runimage
RUN apk add --no-cache ca-certificates

# Copy the binary to the production image from the builder Stage.
COPY --from=builder /main /usr/local/main
COPY --from=builder static /static
RUN mkdir /lib64
RUN ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
# Run the web service on container startup
CMD ["/usr/local/main"]
